<template>
  <div class="container">
    <el-form
      ref="form"
      label-width="80px"
      :model="addParameter"
      :rules="addFromRules"
    >
      <el-form-item label="学科名称" prop="subjectName">
        <el-input
          v-model="addParameter.subjectName"
          placeholder="请输入学科名称"
        ></el-input>
      </el-form-item>
      <el-form-item label="是否显示">
        <el-switch
          active-value="1"
          inactive-value="0"
          v-model="addParameter.isFrontDisplay"
          active-color="#13ce66"
        ></el-switch>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data () {
    return {
      addParameter: {
        subjectName: '',
        isFrontDisplay: 1
      },
      addFromRules: {
        subjectName: [
          { required: true, message: '请输入学科名称', trigger: 'blur' },
          { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
        ]
      }
    }
  },
  updated () {
    this.toSubjects()
  },
  methods: {
    toSubjects () {
      this.$emit('onAddParameter', this.addParameter)
    }
  }
}
</script>

<style scoped lang='less'></style>
